package org.summer.lawyer.handle;

import jakarta.annotation.Resource;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.summer.lawyer.event.SpuCommentEvent;
import org.summer.lawyer.service.ISpuCommentService;

/**
 *
 */
@Getter
@Slf4j
@Component
public class SpuCommentHandle implements ApplicationListener<SpuCommentEvent> {

    @Resource
    private ISpuCommentService spuCommentService;

    @Async
    @Override
    public void onApplicationEvent(SpuCommentEvent event) {
        if (event.getLawFirmId() != null) {
            spuCommentService.calRating(event.getLawFirmId());
        }
    }
}
